<!DOCTYPE html>
<html lang="zh-cn">
<head prefix="og: http://ogp.me/ns#">
  <meta charset="utf-8">
  <title>nuxtjs-axios|axios中文网 | axios</title>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Canonical links -->
  <link rel="canonical" href="http://axios-js.com/zh-cn/docs/nuxtjs-axios.html">
  <!-- Alternative links -->
  
    
      <link rel="alternative" hreflang="en" href="http://axios-js.com/docs/nuxtjs-axios.html">
    
      <link rel="alternative" hreflang="zh-cn" href="http://axios-js.com/zh-cn/docs/nuxtjs-axios.html">
    
  
  <!-- Icon -->
  <link rel="apple-touch-icon" sizes="57x57" href="http://www.axios-js.com/icon/apple-touch-icon-57x57.png">
  <link rel="apple-touch-icon" sizes="114x114" href="http://www.axios-js.com/icon/apple-touch-icon-114x114.png">
  <link rel="apple-touch-icon" sizes="72x72" href="http://www.axios-js.com/icon/apple-touch-icon-72x72.png">
  <link rel="apple-touch-icon" sizes="144x144" href="http://www.axios-js.com/icon/apple-touch-icon-144x144.png">
  <link rel="apple-touch-icon" sizes="60x60" href="http://www.axios-js.com/icon/apple-touch-icon-60x60.png">
  <link rel="apple-touch-icon" sizes="120x120" href="http://www.axios-js.com/icon/apple-touch-icon-120x120.png">
  <link rel="apple-touch-icon" sizes="76x76" href="http://www.axios-js.com/icon/apple-touch-icon-76x76.png">
  <link rel="apple-touch-icon" sizes="152x152" href="http://www.axios-js.com/icon/apple-touch-icon-152x152.png">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-196x196.png" sizes="196x196">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-160x160.png" sizes="160x160">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-96x96.png" sizes="96x96">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-16x16.png" sizes="16x16">
  <link rel="icon" type="image/png" href="http://www.axios-js.com/icon/favicon-32x32.png" sizes="32x32">
  <meta name="msapplication-TileColor" content="#2f83cd">
  <meta name="msapplication-TileImage" content="/icon/mstile-144x144.png">
  <meta name="generator" content="Hexo 4.1.0">
  <!-- CSS -->
  <!-- build:css build/css/navy.css -->
  
<link rel="stylesheet" href="static/css/navy.css">

  <!-- endbuild -->
  <link href="static/css/css.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="static/css/font-awesome.min.css">
  <link rel="stylesheet" href="static/css/docsearch.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css">
  <!-- RSS -->
  <link rel="alternate" href="http://www.axios-js.com/atom.xml" title="axios">
  <!-- Open Graph -->
  <meta name="description" content="nuxtjs-axios中文文档">
<meta property="og:type" content="website">
<meta property="og:title" content="nuxtjs-axios|axios中文网">
<meta property="og:url" content="http://axios-js.com/zh-cn/docs/nuxtjs-axios.html">
<meta property="og:site_name" content="axios">
<meta property="og:description" content="nuxtjs-axios中文文档">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://david-dm.org/nuxt-community/axios-module/status.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/circleci/project/github/nuxt-community/axios-module.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/codecov/c/github/nuxt-community/axios-module.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/npm/v/@nuxtjs/axios/latest.svg?style=flat-square">
<meta property="og:image" content="https://img.shields.io/npm/dt/@nuxtjs/axios.svg?style=flat-square">
<meta property="og:image" content="http://axios-js.com/icon/les01.jpeg">
<meta property="og:image" content="http://axios-js.com/icon/les02.jpeg">
<meta property="og:image" content="http://axios-js.com/icon/les03.jpeg">
<meta property="og:image" content="http://axios-js.com/icon/les04.jpeg">
<meta property="article:published_time" content="2021-10-28T14:06:35.000Z">
<meta property="article:modified_time" content="2021-10-28T14:06:35.000Z">
<meta property="article:author" content="Hexo">
<meta property="article:tag" content="axios 中文">
<meta property="article:tag" content=" axios 中文文档">
<meta property="article:tag" content=" nuxtjs-axios中文">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://david-dm.org/nuxt-community/axios-module/status.svg?style=flat-square">
  <!-- Analytics -->
  
<script>
    (function(h,o,t,j,a,r){
        h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
        h._hjSettings={hjid:1120304,hjsv:6};
        a=o.getElementsByTagName('head')[0];
        r=o.createElement('script');r.async=1;
        r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
        a.appendChild(r);
    })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>

<a title="Real Time Web Analytics" href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/badge.gif" border="0"></a>
<script>var clicky_site_ids = clicky_site_ids || []; clicky_site_ids.push(101192693);</script>
<script async="" src="static/js/js.js"></script>



</head>

<body>
  <div id="container">
    <header id="header" class="wrapper">
  <div id="header-inner" class="inner">
    <h1 id="logo-wrap">
      <a href="index.html" id="logo">axios</a>
    </h1>
    <nav id="main-nav">
      <a href="index1.html" class="main-nav-link">文档</a><a href="index2.html" class="main-nav-link">博客</a>
      <a href="javascript:;" target="_blank" rel="noopener" class="main-nav-link"><i class="fa fa-github-alt"></i></a>
      <div id="search-input-wrap">
        <div id="search-input-icon">
          <i class="fa fa-search"></i>
        </div>
        <input type="search" id="search-input" placeholder="Search...">
      </div>
    </nav>
    <div id="lang-select-wrap">
      <label id="lang-select-label"><i class="fa fa-globe"></i><span>简体中文</span></label>
      <select id="lang-select" data-canonical="docs/nuxtjs-axios.html">
        
          <option value="en">undefined</option>
        
          <option value="zh-cn" selected="">简体中文</option>
        
      </select>
    </div>
    <a id="mobile-nav-toggle">
      <span class="mobile-nav-toggle-bar"></span>
      <span class="mobile-nav-toggle-bar"></span>
      <span class="mobile-nav-toggle-bar"></span>
    </a>
  </div>
</header>

    <div id="content-wrap">
  <div id="content" class="wrapper">
    <div id="content-inner">
      <article class="article-container" itemscope="" itemtype="http://schema.org/Article">
        <div class="article-inner">
          <div class="article">
            <div class="inner">
              <header class="article-header">
                <h1 class="article-title" itemprop="name">nuxtjs-axios|axios中文网</h1>
                <a href="javascript:;" target="_blank" rel="noopener" class="article-edit-link" title="改进本文"></a>
              </header>
              <div class="article-content" itemprop="articleBody">
                <p class="vultr-desc">
                  本站由axios爱好者共建，部署在vultr vps上，推荐使用vultr!价格实惠，实力雄厚。
                  最近新注册用户充值$25,可额外获赠$50,搭建博客必备。
                  <a href="javascript:;" target="_blank" rel="noopener">前往注册</a>
                </p>

                <div id="lagou-vip">
                  <a href="javascript:;" target="_blank" rel="noopener">京东双11，现在不买等一年！犒劳自己--></a>
                </div>
                <h1 id="📦-Axios-模块" class="article-heading"><a href="#📦-Axios-模块" class="headerlink" title="📦 Axios 模块"></a>📦 Axios 模块<a class="article-anchor" href="#📦-Axios-模块" aria-hidden="true"></a></h1><blockquote>
<p>Secure and Easy <a href="javascript:;" target="_blank" rel="noopener">Axios</a> integration with Nuxt.js.</p>
</blockquote>
<p align="center"><br><a href="javascript:;" target="_blank" rel="noopener"><br>    <img alt="" src="https://david-dm.org/nuxt-community/axios-module/status.svg?style=flat-square"><br></a><br><a href="javascript:;" target="_blank" rel="noopener"><br>    <img alt="" src="static/picture/code_style-standard-brightgreen.svg"><br></a><br><a href="javascript:;" target="_blank" rel="noopener"><br>    <img alt="" src="static/picture/axios-module.svg"><br></a><br><a href="javascript:;" target="_blank" rel="noopener"><br>    <img alt="" src="static/picture/axios-module1.svg"><br></a><br><br><br><a href="javascript:;" target="_blank" rel="noopener"><br>    <img alt="" src="static/picture/latest.svg"><br></a><br><a href="javascript:;" target="_blank" rel="noopener"><br>    <img alt="" src="static/picture/axios.svg"><br></a><br></p>

<h2 id="✅-特点" class="article-heading"><a href="#✅-特点" class="headerlink" title="✅ 特点"></a>✅ 特点<a class="article-anchor" href="#✅-特点" aria-hidden="true"></a></h2><p>✓ 无论是客户端还是server端，自动设置 base URL</p>
<p>✓  在<code>$axios</code>对象上暴露 <code>setToken</code>函数方法， 我们能轻而易举的设置认证 tokens</p>
<p>✓ 自动启用 <code>withCredentials</code>特性 当请求发送到base URL时</p>
<p>✓ SSR模式下代理头信息 (Useful for auth)</p>
<p>✓ Fetch 风格的请求</p>
<p>✓ 和Nuxt.js的 Progressbar完美结合</p>
<p>✓ 支持 <a href="javascript:;" target="_blank" rel="noopener">Proxy Module</a></p>
<p>✓ 自动重试机制 <a href="javascript:;" target="_blank" rel="noopener">axios-retry</a></p>
<h2 id="安装" class="article-heading"><a href="#安装" class="headerlink" title="安装"></a>安装<a class="article-anchor" href="#安装" aria-hidden="true"></a></h2><p>使用 yarn:</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">yarn add @nuxtjs/axios</span><br></pre></td></tr></table></figure>
<p>使用 npm:</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">npm install @nuxtjs/axios</span><br></pre></td></tr></table></figure>
<p><strong>nuxt.config.js</strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="built_in">module</span>.exports = &#123;</span><br><span class="line">  modules: [</span><br><span class="line">    <span class="string">'@nuxtjs/axios'</span>,</span><br><span class="line">  ],</span><br><span class="line"></span><br><span class="line">  axios: &#123;</span><br><span class="line">    <span class="comment">// proxyHeaders: false</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="使用" class="article-heading"><a href="#使用" class="headerlink" title="使用"></a>使用<a class="article-anchor" href="#使用" aria-hidden="true"></a></h2><h3 id="组件" class="article-heading"><a href="#组件" class="headerlink" title="组件"></a>组件<a class="article-anchor" href="#组件" aria-hidden="true"></a></h3><p><strong><code>asyncData</code></strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">async</span> asyncData(&#123; app &#125;) &#123;</span><br><span class="line">  <span class="keyword">const</span> ip = <span class="keyword">await</span> app.$axios.$<span class="keyword">get</span>('http://icanhazip.com')</span><br><span class="line">  return &#123; ip &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong><code>methods</code>/<code>created</code>/<code>mounted</code>/etc</strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">methods: &#123;</span><br><span class="line">  <span class="keyword">async</span> fetchSomething() &#123;</span><br><span class="line">    <span class="keyword">const</span> ip = <span class="keyword">await</span> <span class="keyword">this</span>.$axios.$<span class="keyword">get</span>('http://icanhazip.com')</span><br><span class="line">    this.ip = ip</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="Store-nuxtServerInit" class="article-heading"><a href="#Store-nuxtServerInit" class="headerlink" title="Store nuxtServerInit"></a>Store <code>nuxtServerInit</code><a class="article-anchor" href="#Store-nuxtServerInit" aria-hidden="true"></a></h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">async</span> nuxtServerInit (&#123; commit &#125;, &#123; app &#125;) &#123;</span><br><span class="line">  <span class="keyword">const</span> ip = <span class="keyword">await</span> app.$axios.$<span class="keyword">get</span>('http://icanhazip.com')</span><br><span class="line">  commit('SET_IP', ip)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="Store-actions" class="article-heading"><a href="#Store-actions" class="headerlink" title="Store actions"></a>Store actions<a class="article-anchor" href="#Store-actions" aria-hidden="true"></a></h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// In store</span></span><br><span class="line">&#123;</span><br><span class="line">  actions: &#123;</span><br><span class="line">    <span class="keyword">async</span> getIP (&#123; commit &#125;) &#123;</span><br><span class="line">      <span class="keyword">const</span> ip = <span class="keyword">await</span> <span class="keyword">this</span>.$axios.$<span class="keyword">get</span>('http://icanhazip.com')</span><br><span class="line">      commit('SET_IP', ip)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="扩展Axios" class="article-heading"><a href="#扩展Axios" class="headerlink" title="扩展Axios"></a>扩展Axios<a class="article-anchor" href="#扩展Axios" aria-hidden="true"></a></h2><p>如果你需要通过注册拦截器或者改变全局设置来定制化axios, 你需要创建一个nuxt plugin</p>
<p><strong>nuxt.config.js</strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  modules: [</span><br><span class="line">    <span class="string">'@nuxtjs/axios'</span>,</span><br><span class="line">  ],</span><br><span class="line"></span><br><span class="line">  plugins: [</span><br><span class="line">    <span class="string">'~/plugins/axios'</span></span><br><span class="line">  ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>plugins/axios.js</strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="function"><span class="keyword">function</span> (<span class="params">&#123; $axios, redirect &#125;</span>) </span>&#123;</span><br><span class="line">  $axios.onRequest(<span class="function"><span class="params">config</span> =&gt;</span> &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">'Making request to '</span> + config.url)</span><br><span class="line">  &#125;)</span><br><span class="line"></span><br><span class="line">  $axios.onError(<span class="function"><span class="params">error</span> =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">const</span> code = <span class="built_in">parseInt</span>(error.response &amp;&amp; error.response.status)</span><br><span class="line">    <span class="keyword">if</span> (code === <span class="number">400</span>) &#123;</span><br><span class="line">      redirect(<span class="string">'/400'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="帮助" class="article-heading"><a href="#帮助" class="headerlink" title="帮助"></a>帮助<a class="article-anchor" href="#帮助" aria-hidden="true"></a></h2><h3 id="拦截器" class="article-heading"><a href="#拦截器" class="headerlink" title="拦截器"></a>拦截器<a class="article-anchor" href="#拦截器" aria-hidden="true"></a></h3><p>Axios plugin provides helpers to register axios interceptors easier and faster.</p>
<ul>
<li><code>onRequest(config)</code></li>
<li><code>onResponse(response)</code></li>
<li><code>onError(err)</code></li>
<li><code>onRequestError(err)</code></li>
<li><code>onResponseError(err)</code></li>
</ul>
<p>These functions don’t have to return anything by default.</p>
<p>Example: (<code>plugins/axios.js</code>)</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="function"><span class="keyword">function</span> (<span class="params">&#123; $axios, redirect &#125;</span>) </span>&#123;</span><br><span class="line">  $axios.onError(<span class="function"><span class="params">error</span> =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">if</span>(error.code === <span class="number">500</span>) &#123;</span><br><span class="line">      redirect(<span class="string">'/sorry'</span>)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="Fetch-风格请求" class="article-heading"><a href="#Fetch-风格请求" class="headerlink" title="Fetch 风格请求"></a>Fetch 风格请求<a class="article-anchor" href="#Fetch-风格请求" aria-hidden="true"></a></h3><p>Axios plugin also supports fetch style requests with <code>$</code> prefixed methods:</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// Normal usage with axios</span></span><br><span class="line"><span class="keyword">let</span> data = (<span class="keyword">await</span> $axios.get(<span class="string">'...'</span>)).data</span><br><span class="line"></span><br><span class="line"><span class="comment">// Fetch Style</span></span><br><span class="line"><span class="keyword">let</span> data = <span class="keyword">await</span> $axios.$<span class="keyword">get</span>('...')</span><br></pre></td></tr></table></figure>
<h3 id="setHeader-name-value-scopes-39-common-39" class="article-heading"><a href="#setHeader-name-value-scopes-39-common-39" class="headerlink" title="setHeader(name, value, scopes=&#39;common&#39;)"></a><code>setHeader(name, value, scopes=&#39;common&#39;)</code><a class="article-anchor" href="#setHeader-name-value-scopes-39-common-39" aria-hidden="true"></a></h3><p>Axios 对象非常方面设置header部分</p>
<p>参数:</p>
<ul>
<li><strong>name</strong>: Name of the header</li>
<li><strong>value</strong>: Value of the header</li>
<li><strong>scopes</strong>: Send only on specific type of requests. Defaults<ul>
<li>Type: <em>Array</em> or <em>String</em></li>
<li>Defaults to <code>common</code> meaning all types of requests</li>
<li>Can be <code>get</code>, <code>post</code>, <code>delete</code>, …</li>
</ul>
</li>
</ul>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// Adds header: `Authorization: 123` to all requests</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setHeader(<span class="string">'Authorization'</span>, <span class="string">'123'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// Overrides `Authorization` header with new value</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setHeader(<span class="string">'Authorization'</span>, <span class="string">'456'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// Adds header: `Content-Type: application/x-www-form-urlencoded` to only post requests</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setHeader(<span class="string">'Content-Type'</span>, <span class="string">'application/x-www-form-urlencoded'</span>, [</span><br><span class="line">  <span class="string">'post'</span></span><br><span class="line">])</span><br><span class="line"></span><br><span class="line"><span class="comment">// Removes default Content-Type header from `post` scope</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setHeader(<span class="string">'Content-Type'</span>, <span class="literal">false</span>, [<span class="string">'post'</span>])</span><br></pre></td></tr></table></figure>
<h3 id="setToken-token-type-scopes-39-common-39" class="article-heading"><a href="#setToken-token-type-scopes-39-common-39" class="headerlink" title="setToken(token, type, scopes=&#39;common&#39;)"></a><code>setToken(token, type, scopes=&#39;common&#39;)</code><a class="article-anchor" href="#setToken-token-type-scopes-39-common-39" aria-hidden="true"></a></h3><p>Axios实例可以方便的设置全局头信息</p>
<p>Parameters:</p>
<ul>
<li><strong>token</strong>: 认证需要的token</li>
<li><strong>type</strong>: 认证token前缀(Usually <code>Bearer</code>).</li>
<li><strong>scopes</strong>: 用于特定请求设置. Defaults<ul>
<li>Type: <em>Array</em> or <em>String</em></li>
<li>Defaults to <code>common</code> meaning all types of requests</li>
<li>Can be <code>get</code>, <code>post</code>, <code>delete</code>, …</li>
</ul>
</li>
</ul>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// Adds header: `Authorization: 123` to all requests</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setToken(<span class="string">'123'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// Overrides `Authorization` header with new value</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setToken(<span class="string">'456'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// Adds header: `Authorization: Bearer 123` to all requests</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setToken(<span class="string">'123'</span>, <span class="string">'Bearer'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// Adds header: `Authorization: Bearer 123` to only post and delete requests</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setToken(<span class="string">'123'</span>, <span class="string">'Bearer'</span>, [<span class="string">'post'</span>, <span class="string">'delete'</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment">// Removes default Authorization header from `common` scope (all requests)</span></span><br><span class="line"><span class="keyword">this</span>.$axios.setToken(<span class="literal">false</span>)</span><br></pre></td></tr></table></figure>
<h2 id="选项" class="article-heading"><a href="#选项" class="headerlink" title="选项"></a>选项<a class="article-anchor" href="#选项" aria-hidden="true"></a></h2><p>You can pass options using module options or <code>axios</code> section in <code>nuxt.config.js</code></p>
<h3 id="prefix-host-and-port" class="article-heading"><a href="#prefix-host-and-port" class="headerlink" title="prefix, host and port"></a><code>prefix</code>, <code>host</code> and <code>port</code><a class="article-anchor" href="#prefix-host-and-port" aria-hidden="true"></a></h3><p>用来配置 <code>baseURL</code> and <code>browserBaseURL</code>部分。</p>
<p>可以使用 <code>API_PREFIX</code>, <code>API_HOST</code> (or <code>HOST</code>) and <code>API_PORT</code> (or <code>PORT</code>) 环境变量.</p>
<p> <code>prefix</code>的默认值是<code>/</code>.</p>
<h3 id="baseURL" class="article-heading"><a href="#baseURL" class="headerlink" title="baseURL"></a><code>baseURL</code><a class="article-anchor" href="#baseURL" aria-hidden="true"></a></h3><ul>
<li>默认值: <code>http://[HOST]:[PORT][PREFIX]</code></li>
</ul>
<p>Base URL 是用于在 server side 模式下的请求配置.</p>
<p>环境变量 <code>API_URL</code> 可以覆盖 <strong>override</strong> <code>baseURL</code>设置</p>
<h3 id="browserBaseURL" class="article-heading"><a href="#browserBaseURL" class="headerlink" title="browserBaseURL"></a><code>browserBaseURL</code><a class="article-anchor" href="#browserBaseURL" aria-hidden="true"></a></h3><ul>
<li>Default: <code>baseURL</code> (or <code>prefix</code> when <code>options.proxy</code> is enabled)</li>
</ul>
<p>Base URL 适用于客户端模式下的配置.</p>
<p>环境变量 <code>API_URL_BROWSER</code> 可以覆盖 <strong>override</strong> <code>browserBaseURL</code>.</p>
<h3 id="https" class="article-heading"><a href="#https" class="headerlink" title="https"></a><code>https</code><a class="article-anchor" href="#https" aria-hidden="true"></a></h3><ul>
<li>默认: <code>false</code></li>
</ul>
<p>If set to <code>true</code>, <code>http://</code> in both <code>baseURL</code> and <code>browserBaseURL</code> will be changed into <code>https://</code>.</p>
<h3 id="progress" class="article-heading"><a href="#progress" class="headerlink" title="progress"></a><code>progress</code><a class="article-anchor" href="#progress" aria-hidden="true"></a></h3><ul>
<li>默认: <code>true</code></li>
</ul>
<p>和 Nuxt.js progress bar 一起用于显示loading状态 (仅在浏览器上，且loading bar可用)</p>
<p>你可以禁止适用这项配置</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">this</span>.$axios.$<span class="keyword">get</span>('URL', &#123; progress: <span class="literal">false</span> &#125;)</span><br></pre></td></tr></table></figure>
<h3 id="proxy" class="article-heading"><a href="#proxy" class="headerlink" title="proxy"></a><code>proxy</code><a class="article-anchor" href="#proxy" aria-hidden="true"></a></h3><ul>
<li>Default: <code>false</code></li>
</ul>
<p>You can easily integrate Axios with <a href="javascript:;" target="_blank" rel="noopener">Proxy Module</a> and is much recommended to prevent CORS and deployment problems.</p>
<p><strong>nuxt.config.js</strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  modules: [</span><br><span class="line">    <span class="string">'@nuxtjs/axios'</span></span><br><span class="line">  ],</span><br><span class="line"></span><br><span class="line">  axios: &#123;</span><br><span class="line">    proxy: <span class="literal">true</span> <span class="comment">// Can be also an object with default options</span></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  proxy: &#123;</span><br><span class="line">    <span class="string">'/api/'</span>: <span class="string">'http://api.example.com'</span>,</span><br><span class="line">    <span class="string">'/api2/'</span>: <span class="string">'http://api.another-website.com'</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>Note:</strong> It is not required to manually register <code>@nuxtjs/proxy</code> module, but it does need to be in your dependencies.</p>
<p><strong>Note:</strong> <code>/api/</code> will be added to all requests to the API end point. If you need to remove it use <code>pathRewrite</code>:</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">proxy: &#123;</span><br><span class="line">  <span class="string">'/api/'</span>: &#123; <span class="attr">target</span>: <span class="string">'http://api.example.com'</span>, <span class="attr">pathRewrite</span>: &#123;<span class="string">'^/api/'</span>: <span class="string">''</span>&#125; &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="retry" class="article-heading"><a href="#retry" class="headerlink" title="retry"></a><code>retry</code><a class="article-anchor" href="#retry" aria-hidden="true"></a></h3><ul>
<li><p>Default: <code>false</code></p>
<p>Automatically intercept failed requests and retries them whenever posible using <a href="javascript:;" target="_blank" rel="noopener">axios-retry</a>.</p>
</li>
</ul>
<p>By default, number of retries will be <strong>3 times</strong>, if <code>retry</code> value is set to <code>true</code>. You can change it by passing an object like this:</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">axios: &#123;</span><br><span class="line">  retry: &#123; <span class="attr">retries</span>: <span class="number">3</span> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="credentials" class="article-heading"><a href="#credentials" class="headerlink" title="credentials"></a><code>credentials</code><a class="article-anchor" href="#credentials" aria-hidden="true"></a></h3><ul>
<li>Default: <code>false</code></li>
</ul>
<p>Adds an interceptor to automatically set <code>withCredentials</code> config of axios when requesting to <code>baseUrl</code><br>which allows passing authentication headers to backend.</p>
<h3 id="debug" class="article-heading"><a href="#debug" class="headerlink" title="debug"></a><code>debug</code><a class="article-anchor" href="#debug" aria-hidden="true"></a></h3><ul>
<li>Default: <code>false</code></li>
</ul>
<p>Adds interceptors to log request and responses.</p>
<h3 id="proxyHeaders" class="article-heading"><a href="#proxyHeaders" class="headerlink" title="proxyHeaders"></a><code>proxyHeaders</code><a class="article-anchor" href="#proxyHeaders" aria-hidden="true"></a></h3><ul>
<li>Default: <code>true</code></li>
</ul>
<p>In SSR context, sets client request header as axios default request headers.<br>This is useful for making requests which need cookie based auth on server side.<br>Also helps making consistent requests in both SSR and Client Side code.</p>
<blockquote>
<p><strong>NOTE:</strong> If directing requests at a url protected by CloudFlare’s CDN you should set this to false to prevent CloudFlare from mistakenly detecting a reverse proxy loop and returning a 403 error.</p>
</blockquote>
<h3 id="proxyHeadersIgnore" class="article-heading"><a href="#proxyHeadersIgnore" class="headerlink" title="proxyHeadersIgnore"></a><code>proxyHeadersIgnore</code><a class="article-anchor" href="#proxyHeadersIgnore" aria-hidden="true"></a></h3><ul>
<li>Default <code>[&#39;host&#39;, &#39;accept&#39;]</code></li>
</ul>
<p>Only efficient when <code>proxyHeaders</code> is set to true. Removes unwanted request headers to the API backend in SSR.</p>
<h2 id="From-4-x-to-5-x" class="article-heading"><a href="#From-4-x-to-5-x" class="headerlink" title="From 4.x to 5.x"></a>From 4.x to 5.x<a class="article-anchor" href="#From-4-x-to-5-x" aria-hidden="true"></a></h2><p><strong>BaseURL options and handling have been completely rewritten.</strong></p>
<p>Please refer to the latest docs.</p>
<p><strong>Default prefix is now <code>/</code> instead of <code>/api</code>.</strong></p>
<p>You have to explicitly add <code>/api/</code> in all requests.</p>
<p><strong><code>credentials</code> is now disabled by default.</strong></p>
<p>For using old defaults:</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  axios: &#123;</span><br><span class="line">    prefix: <span class="string">'/api'</span>,</span><br><span class="line">    credentials: <span class="literal">true</span>    </span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>Default error interceptor removed</strong></p>
<p><strong>All lifecycle functions removed</strong></p>
<p>You can now easily use a plugin to extend axios and add your custom logic there. </p>
<p>Please see <a href="javascript:;" target="_blank" rel="noopener">Extending Axios</a> section in docs.</p>
<h1 id="Change-Log" class="article-heading"><a href="#Change-Log" class="headerlink" title="Change Log"></a>Change Log<a class="article-anchor" href="#Change-Log" aria-hidden="true"></a></h1><p>All notable changes to this project will be documented in this file. See <a href="javascript:;" target="_blank" rel="noopener">standard-version</a> for commit guidelines.</p>
<p><a name="5.3.2"></a></p>
<h2 id="5-3-2-2018-09-21" class="article-heading"><a href="#5-3-2-2018-09-21" class="headerlink" title="5.3.2 (2018-09-21)"></a><a href="javascript:;" target="_blank" rel="noopener">5.3.2</a> (2018-09-21)<a class="article-anchor" href="#5-3-2-2018-09-21" aria-hidden="true"></a></h2><h3 id="Bug-Fixes" class="article-heading"><a href="#Bug-Fixes" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes" aria-hidden="true"></a></h3><ul>
<li><strong>types:</strong> replace AxiosPromise to Promise (<a href="javascript:;" target="_blank" rel="noopener">#162</a>) (<a href="javascript:;" target="_blank" rel="noopener">5fd9214</a>)</li>
</ul>
<p><a name="5.3.1"></a></p>
<h2 id="5-3-1-2018-03-31" class="article-heading"><a href="#5-3-1-2018-03-31" class="headerlink" title="5.3.1 (2018-03-31)"></a><a href="javascript:;" target="_blank" rel="noopener">5.3.1</a> (2018-03-31)<a class="article-anchor" href="#5-3-1-2018-03-31" aria-hidden="true"></a></h2><p><a name="5.3.0"></a></p>
<h1 id="5-3-0-2018-03-31" class="article-heading"><a href="#5-3-0-2018-03-31" class="headerlink" title="5.3.0 (2018-03-31)"></a><a href="javascript:;" target="_blank" rel="noopener">5.3.0</a> (2018-03-31)<a class="article-anchor" href="#5-3-0-2018-03-31" aria-hidden="true"></a></h1><h3 id="Features" class="article-heading"><a href="#Features" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features" aria-hidden="true"></a></h3><ul>
<li>CLI improvements (<a href="javascript:;" target="_blank" rel="noopener">481e6da</a>)</li>
</ul>
<p><a name="5.2.0"></a></p>
<h1 id="5-2-0-2018-03-31" class="article-heading"><a href="#5-2-0-2018-03-31" class="headerlink" title="5.2.0 (2018-03-31)"></a><a href="javascript:;" target="_blank" rel="noopener">5.2.0</a> (2018-03-31)<a class="article-anchor" href="#5-2-0-2018-03-31" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-1" class="article-heading"><a href="#Bug-Fixes-1" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-1" aria-hidden="true"></a></h3><ul>
<li><strong>progress:</strong> onProgress when currentRequests is zero (<a href="javascript:;" target="_blank" rel="noopener">#118</a>) (<a href="javascript:;" target="_blank" rel="noopener">a90236e</a>)</li>
</ul>
<h3 id="Features-1" class="article-heading"><a href="#Features-1" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-1" aria-hidden="true"></a></h3><ul>
<li>consola integration (<a href="javascript:;" target="_blank" rel="noopener">4ec3b5d</a>)</li>
</ul>
<p><a name="5.1.1"></a></p>
<h2 id="5-1-1-2018-03-06" class="article-heading"><a href="#5-1-1-2018-03-06" class="headerlink" title="5.1.1 (2018-03-06)"></a><a href="javascript:;" target="_blank" rel="noopener">5.1.1</a> (2018-03-06)<a class="article-anchor" href="#5-1-1-2018-03-06" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-2" class="article-heading"><a href="#Bug-Fixes-2" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-2" aria-hidden="true"></a></h3><ul>
<li><strong>progress:</strong> handle division by zero (<a href="javascript:;" target="_blank" rel="noopener">#117</a>) (<a href="javascript:;" target="_blank" rel="noopener">040eaf7</a>), closes <a href="javascript:;" target="_blank" rel="noopener">#166</a></li>
</ul>
<p><a name="5.1.0"></a></p>
<h1 id="5-1-0-2018-03-05" class="article-heading"><a href="#5-1-0-2018-03-05" class="headerlink" title="5.1.0 (2018-03-05)"></a><a href="javascript:;" target="_blank" rel="noopener">5.1.0</a> (2018-03-05)<a class="article-anchor" href="#5-1-0-2018-03-05" aria-hidden="true"></a></h1><h3 id="Features-2" class="article-heading"><a href="#Features-2" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-2" aria-hidden="true"></a></h3><ul>
<li>allow disable progress per request. closes <a href="javascript:;" target="_blank" rel="noopener">#112</a>. (<a href="javascript:;" target="_blank" rel="noopener">1530bb6</a>)</li>
<li>disable https for localhost url (<a href="javascript:;" target="_blank" rel="noopener">#93</a>) (<a href="javascript:;" target="_blank" rel="noopener">dd67734</a>)</li>
</ul>
<p><a name="5.0.1"></a></p>
<h2 id="5-0-1-2018-02-08" class="article-heading"><a href="#5-0-1-2018-02-08" class="headerlink" title="5.0.1 (2018-02-08)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.1</a> (2018-02-08)<a class="article-anchor" href="#5-0-1-2018-02-08" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-3" class="article-heading"><a href="#Bug-Fixes-3" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-3" aria-hidden="true"></a></h3><ul>
<li>don’t mutate env.API_URL (<a href="javascript:;" target="_blank" rel="noopener">a8ea331</a>)</li>
</ul>
<p><a name="5.0.0"></a></p>
<h1 id="5-0-0-2018-02-04" class="article-heading"><a href="#5-0-0-2018-02-04" class="headerlink" title="5.0.0 (2018-02-04)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.0</a> (2018-02-04)<a class="article-anchor" href="#5-0-0-2018-02-04" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-4" class="article-heading"><a href="#Bug-Fixes-4" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-4" aria-hidden="true"></a></h3><ul>
<li><strong>progress:</strong> finish on fail (<a href="javascript:;" target="_blank" rel="noopener">ea7b569</a>)</li>
</ul>
<h3 id="Features-3" class="article-heading"><a href="#Features-3" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-3" aria-hidden="true"></a></h3><ul>
<li>https option (<a href="javascript:;" target="_blank" rel="noopener">#57</a>) (<a href="javascript:;" target="_blank" rel="noopener">9ecb547</a>)</li>
<li>passing options via proxy option (<a href="javascript:;" target="_blank" rel="noopener">a923db3</a>)</li>
<li>support retry with axios-retry (<a href="javascript:;" target="_blank" rel="noopener">7221cac</a>), closes <a href="javascript:;" target="_blank" rel="noopener">#77</a></li>
</ul>
<p><a name="5.0.0-rc.2"></a></p>
<h1 id="5-0-0-rc-2-2018-01-29" class="article-heading"><a href="#5-0-0-rc-2-2018-01-29" class="headerlink" title="5.0.0-rc.2 (2018-01-29)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.0-rc.2</a> (2018-01-29)<a class="article-anchor" href="#5-0-0-rc-2-2018-01-29" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-5" class="article-heading"><a href="#Bug-Fixes-5" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-5" aria-hidden="true"></a></h3><ul>
<li><strong>package:</strong> require <a href="javascript:;" target="_blank" rel="noopener">@nuxtjs</a>/proxy as a peerDependency (<a href="javascript:;" target="_blank" rel="noopener">fd1ef47</a>)</li>
<li>support dynamic API_URL for SSR (<a href="javascript:;" target="_blank" rel="noopener">ea4882a</a>)</li>
</ul>
<p><a name="5.0.0-rc.1"></a></p>
<h1 id="5-0-0-rc-1-2018-01-28" class="article-heading"><a href="#5-0-0-rc-1-2018-01-28" class="headerlink" title="5.0.0-rc.1 (2018-01-28)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.0-rc.1</a> (2018-01-28)<a class="article-anchor" href="#5-0-0-rc-1-2018-01-28" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-6" class="article-heading"><a href="#Bug-Fixes-6" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-6" aria-hidden="true"></a></h3><ul>
<li><strong>progress:</strong> ensure $loading is valid (<a href="javascript:;" target="_blank" rel="noopener">cbdc586</a>)</li>
</ul>
<p><a name="5.0.0-rc.0"></a></p>
<h1 id="5-0-0-rc-0-2018-01-28" class="article-heading"><a href="#5-0-0-rc-0-2018-01-28" class="headerlink" title="5.0.0-rc.0 (2018-01-28)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.0-rc.0</a> (2018-01-28)<a class="article-anchor" href="#5-0-0-rc-0-2018-01-28" aria-hidden="true"></a></h1><h3 id="Features-4" class="article-heading"><a href="#Features-4" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-4" aria-hidden="true"></a></h3><ul>
<li>support proxy (<a href="javascript:;" target="_blank" rel="noopener">0d3be17</a>)</li>
</ul>
<p><a name="5.0.0-alpha.1"></a></p>
<h1 id="5-0-0-alpha-1-2018-01-28" class="article-heading"><a href="#5-0-0-alpha-1-2018-01-28" class="headerlink" title="5.0.0-alpha.1 (2018-01-28)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.0-alpha.1</a> (2018-01-28)<a class="article-anchor" href="#5-0-0-alpha-1-2018-01-28" aria-hidden="true"></a></h1><h3 id="Features-5" class="article-heading"><a href="#Features-5" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-5" aria-hidden="true"></a></h3><ul>
<li>integrate with nuxt progress bar (<a href="javascript:;" target="_blank" rel="noopener">41a0964</a>)</li>
</ul>
<p><a name="5.0.0-alpha.0"></a></p>
<h1 id="5-0-0-alpha-0-2018-01-28" class="article-heading"><a href="#5-0-0-alpha-0-2018-01-28" class="headerlink" title="5.0.0-alpha.0 (2018-01-28)"></a><a href="javascript:;" target="_blank" rel="noopener">5.0.0-alpha.0</a> (2018-01-28)<a class="article-anchor" href="#5-0-0-alpha-0-2018-01-28" aria-hidden="true"></a></h1><h3 id="Code-Refactoring" class="article-heading"><a href="#Code-Refactoring" class="headerlink" title="Code Refactoring"></a>Code Refactoring<a class="article-anchor" href="#Code-Refactoring" aria-hidden="true"></a></h3><ul>
<li>a better and more stable way to specify baseURL and browserBaseURL options (<a href="javascript:;" target="_blank" rel="noopener">533cf4e</a>)</li>
</ul>
<h3 id="Features-6" class="article-heading"><a href="#Features-6" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-6" aria-hidden="true"></a></h3><ul>
<li>interceptor helpers (<a href="javascript:;" target="_blank" rel="noopener">fa3eb47</a>)</li>
<li>rewrite plugin (<a href="javascript:;" target="_blank" rel="noopener">647b58f</a>)</li>
</ul>
<h3 id="BREAKING-CHANGES" class="article-heading"><a href="#BREAKING-CHANGES" class="headerlink" title="BREAKING CHANGES"></a>BREAKING CHANGES<a class="article-anchor" href="#BREAKING-CHANGES" aria-hidden="true"></a></h3><ul>
<li>prefix should be set to <code>/api</code> for backward compability. refer to new docs.</li>
</ul>
<p><a name="4.5.2"></a></p>
<h2 id="4-5-2-2017-12-29" class="article-heading"><a href="#4-5-2-2017-12-29" class="headerlink" title="4.5.2 (2017-12-29)"></a><a href="javascript:;" target="_blank" rel="noopener">4.5.2</a> (2017-12-29)<a class="article-anchor" href="#4-5-2-2017-12-29" aria-hidden="true"></a></h2><p><a name="4.5.1"></a></p>
<h2 id="4-5-1-2017-12-29" class="article-heading"><a href="#4-5-1-2017-12-29" class="headerlink" title="4.5.1 (2017-12-29)"></a><a href="javascript:;" target="_blank" rel="noopener">4.5.1</a> (2017-12-29)<a class="article-anchor" href="#4-5-1-2017-12-29" aria-hidden="true"></a></h2><p><a name="4.5.0"></a></p>
<h1 id="4-5-0-2017-11-16" class="article-heading"><a href="#4-5-0-2017-11-16" class="headerlink" title="4.5.0 (2017-11-16)"></a><a href="javascript:;" target="_blank" rel="noopener">4.5.0</a> (2017-11-16)<a class="article-anchor" href="#4-5-0-2017-11-16" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-7" class="article-heading"><a href="#Bug-Fixes-7" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-7" aria-hidden="true"></a></h3><ul>
<li>link to the proxy page (<a href="javascript:;" target="_blank" rel="noopener">5449939</a>)</li>
</ul>
<h3 id="Features-7" class="article-heading"><a href="#Features-7" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-7" aria-hidden="true"></a></h3><ul>
<li>disable sefault error handler (<a href="javascript:;" target="_blank" rel="noopener">#44</a>) (<a href="javascript:;" target="_blank" rel="noopener">f1e95ff</a>)</li>
</ul>
<p><a name="4.4.0"></a></p>
<h1 id="4-4-0-2017-09-30" class="article-heading"><a href="#4-4-0-2017-09-30" class="headerlink" title="4.4.0 (2017-09-30)"></a><a href="javascript:;" target="_blank" rel="noopener">4.4.0</a> (2017-09-30)<a class="article-anchor" href="#4-4-0-2017-09-30" aria-hidden="true"></a></h1><h3 id="Features-8" class="article-heading"><a href="#Features-8" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-8" aria-hidden="true"></a></h3><ul>
<li><strong>proxyHeader:</strong> proxyHeadersIgnore option (<a href="javascript:;" target="_blank" rel="noopener">7c13655</a>)</li>
</ul>
<p><a name="4.3.1"></a></p>
<h2 id="4-3-1-2017-09-28" class="article-heading"><a href="#4-3-1-2017-09-28" class="headerlink" title="4.3.1 (2017-09-28)"></a><a href="javascript:;" target="_blank" rel="noopener">4.3.1</a> (2017-09-28)<a class="article-anchor" href="#4-3-1-2017-09-28" aria-hidden="true"></a></h2><p><a name="4.3.0"></a></p>
<h1 id="4-3-0-2017-09-11" class="article-heading"><a href="#4-3-0-2017-09-11" class="headerlink" title="4.3.0 (2017-09-11)"></a><a href="javascript:;" target="_blank" rel="noopener">4.3.0</a> (2017-09-11)<a class="article-anchor" href="#4-3-0-2017-09-11" aria-hidden="true"></a></h1><h3 id="Features-9" class="article-heading"><a href="#Features-9" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-9" aria-hidden="true"></a></h3><ul>
<li>don’t rely on hostname for default values (<a href="javascript:;" target="_blank" rel="noopener">dadd7d8</a>)</li>
</ul>
<p><a name="4.2.1"></a></p>
<h2 id="4-2-1-2017-09-08" class="article-heading"><a href="#4-2-1-2017-09-08" class="headerlink" title="4.2.1 (2017-09-08)"></a><a href="javascript:;" target="_blank" rel="noopener">4.2.1</a> (2017-09-08)<a class="article-anchor" href="#4-2-1-2017-09-08" aria-hidden="true"></a></h2><p><a name="4.2.0"></a></p>
<h1 id="4-2-0-2017-09-08" class="article-heading"><a href="#4-2-0-2017-09-08" class="headerlink" title="4.2.0 (2017-09-08)"></a><a href="javascript:;" target="_blank" rel="noopener">4.2.0</a> (2017-09-08)<a class="article-anchor" href="#4-2-0-2017-09-08" aria-hidden="true"></a></h1><h3 id="Features-10" class="article-heading"><a href="#Features-10" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-10" aria-hidden="true"></a></h3><ul>
<li>pass ctx to errorHandlers (<a href="javascript:;" target="_blank" rel="noopener">c70749a</a>)</li>
</ul>
<p><a name="4.1.1"></a></p>
<h2 id="4-1-1-2017-09-06" class="article-heading"><a href="#4-1-1-2017-09-06" class="headerlink" title="4.1.1 (2017-09-06)"></a><a href="javascript:;" target="_blank" rel="noopener">4.1.1</a> (2017-09-06)<a class="article-anchor" href="#4-1-1-2017-09-06" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-8" class="article-heading"><a href="#Bug-Fixes-8" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-8" aria-hidden="true"></a></h3><ul>
<li>delete accept header (<a href="javascript:;" target="_blank" rel="noopener">2f04e30</a>), closes <a href="javascript:;" target="_blank" rel="noopener">#12</a></li>
</ul>
<p><a name="4.1.0"></a></p>
<h1 id="4-1-0-2017-09-06" class="article-heading"><a href="#4-1-0-2017-09-06" class="headerlink" title="4.1.0 (2017-09-06)"></a><a href="javascript:;" target="_blank" rel="noopener">4.1.0</a> (2017-09-06)<a class="article-anchor" href="#4-1-0-2017-09-06" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-9" class="article-heading"><a href="#Bug-Fixes-9" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-9" aria-hidden="true"></a></h3><ul>
<li>inject $axios in current ctx (<a href="javascript:;" target="_blank" rel="noopener">356b31f</a>)</li>
</ul>
<h3 id="Features-11" class="article-heading"><a href="#Features-11" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-11" aria-hidden="true"></a></h3><ul>
<li>add options.init (<a href="javascript:;" target="_blank" rel="noopener">8e0c0e8</a>)</li>
</ul>
<h3 id="Performance-Improvements" class="article-heading"><a href="#Performance-Improvements" class="headerlink" title="Performance Improvements"></a>Performance Improvements<a class="article-anchor" href="#Performance-Improvements" aria-hidden="true"></a></h3><ul>
<li>move init outside of plugin (<a href="javascript:;" target="_blank" rel="noopener">bcd4710</a>)</li>
</ul>
<p><a name="4.0.1"></a></p>
<h2 id="4-0-1-2017-09-04" class="article-heading"><a href="#4-0-1-2017-09-04" class="headerlink" title="4.0.1 (2017-09-04)"></a><a href="javascript:;" target="_blank" rel="noopener">4.0.1</a> (2017-09-04)<a class="article-anchor" href="#4-0-1-2017-09-04" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-10" class="article-heading"><a href="#Bug-Fixes-10" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-10" aria-hidden="true"></a></h3><ul>
<li><strong>package:</strong> make nuxt devDependency (<a href="javascript:;" target="_blank" rel="noopener">a36a886</a>)</li>
</ul>
<p><a name="4.0.0"></a></p>
<h1 id="4-0-0-2017-08-30" class="article-heading"><a href="#4-0-0-2017-08-30" class="headerlink" title="4.0.0 (2017-08-30)"></a><a href="javascript:;" target="_blank" rel="noopener">4.0.0</a> (2017-08-30)<a class="article-anchor" href="#4-0-0-2017-08-30" aria-hidden="true"></a></h1><h3 id="Features-12" class="article-heading"><a href="#Features-12" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-12" aria-hidden="true"></a></h3><ul>
<li>better baseURL message (<a href="javascript:;" target="_blank" rel="noopener">61432a1</a>)</li>
<li>responseInterceptor and errorHandler (<a href="javascript:;" target="_blank" rel="noopener">b16d6bf</a>)</li>
<li>upgrade for nuxt rc8 (<a href="javascript:;" target="_blank" rel="noopener">a341185</a>)</li>
</ul>
<h3 id="BREAKING-CHANGES-1" class="article-heading"><a href="#BREAKING-CHANGES-1" class="headerlink" title="BREAKING CHANGES"></a>BREAKING CHANGES<a class="article-anchor" href="#BREAKING-CHANGES-1" aria-hidden="true"></a></h3><ul>
<li>app.axios is not available anymore (without $) should always use app.$axios</li>
</ul>
<p><a name="3.1.4"></a></p>
<h2 id="3-1-4-2017-08-13" class="article-heading"><a href="#3-1-4-2017-08-13" class="headerlink" title="3.1.4 (2017-08-13)"></a><a href="javascript:;" target="_blank" rel="noopener">3.1.4</a> (2017-08-13)<a class="article-anchor" href="#3-1-4-2017-08-13" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-11" class="article-heading"><a href="#Bug-Fixes-11" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-11" aria-hidden="true"></a></h3><ul>
<li>create fresh objects for all default header scopes (<a href="javascript:;" target="_blank" rel="noopener">7ba3ae8</a>)</li>
</ul>
<p><a name="3.1.3"></a></p>
<h2 id="3-1-3-2017-08-13" class="article-heading"><a href="#3-1-3-2017-08-13" class="headerlink" title="3.1.3 (2017-08-13)"></a><a href="javascript:;" target="_blank" rel="noopener">3.1.3</a> (2017-08-13)<a class="article-anchor" href="#3-1-3-2017-08-13" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-12" class="article-heading"><a href="#Bug-Fixes-12" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-12" aria-hidden="true"></a></h3><ul>
<li><strong>headers:</strong> fix security bug with default request headers (<a href="javascript:;" target="_blank" rel="noopener">9355228</a>)</li>
</ul>
<p><a name="3.1.1"></a></p>
<h2 id="3-1-1-2017-08-13" class="article-heading"><a href="#3-1-1-2017-08-13" class="headerlink" title="3.1.1 (2017-08-13)"></a>3.1.1 (2017-08-13)<a class="article-anchor" href="#3-1-1-2017-08-13" aria-hidden="true"></a></h2><p> (repository moved from nuxt-community/modules)</p>
<h3 id="Features-13" class="article-heading"><a href="#Features-13" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-13" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> fetch style requests</li>
</ul>
<p><a name="3.0.1"></a></p>
<h2 id="3-0-1-2017-07-25" class="article-heading"><a href="#3-0-1-2017-07-25" class="headerlink" title="3.0.1 (2017-07-25)"></a><a href="javascript:;" target="_blank" rel="noopener">3.0.1</a> (2017-07-25)<a class="article-anchor" href="#3-0-1-2017-07-25" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-13" class="article-heading"><a href="#Bug-Fixes-13" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-13" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> typo in default headers (<a href="javascript:;" target="_blank" rel="noopener">9697559</a>)</li>
</ul>
<p><a name="3.0.0"></a></p>
<h1 id="3-0-0-2017-07-25" class="article-heading"><a href="#3-0-0-2017-07-25" class="headerlink" title="3.0.0 (2017-07-25)"></a><a href="javascript:;" target="_blank" rel="noopener">3.0.0</a> (2017-07-25)<a class="article-anchor" href="#3-0-0-2017-07-25" aria-hidden="true"></a></h1><h3 id="Code-Refactoring-1" class="article-heading"><a href="#Code-Refactoring-1" class="headerlink" title="Code Refactoring"></a>Code Refactoring<a class="article-anchor" href="#Code-Refactoring-1" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> remove $ shortcut mixins (<a href="javascript:;" target="_blank" rel="noopener">1ab2bd6</a>)</li>
</ul>
<h3 id="BREAKING-CHANGES-2" class="article-heading"><a href="#BREAKING-CHANGES-2" class="headerlink" title="BREAKING CHANGES"></a>BREAKING CHANGES<a class="article-anchor" href="#BREAKING-CHANGES-2" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> You have to explicitly use <code>this.$axios.[method]</code> instead of <code>this.$[method]</code></li>
</ul>
<p><a name="2.3.0"></a></p>
<h1 id="2-3-0-2017-07-24" class="article-heading"><a href="#2-3-0-2017-07-24" class="headerlink" title="2.3.0 (2017-07-24)"></a><a href="javascript:;" target="_blank" rel="noopener">2.3.0</a> (2017-07-24)<a class="article-anchor" href="#2-3-0-2017-07-24" aria-hidden="true"></a></h1><h3 id="Features-14" class="article-heading"><a href="#Features-14" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-14" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> optionally disable error handling (#74) (<a href="javascript:;" target="_blank" rel="noopener">a195feb</a>)</li>
<li><strong>axios:</strong> redirectError (<a href="javascript:;" target="_blank" rel="noopener">4ce1a1c</a>)</li>
</ul>
<p><a name="2.2.4"></a></p>
<h2 id="2-2-4-2017-07-20" class="article-heading"><a href="#2-2-4-2017-07-20" class="headerlink" title="2.2.4 (2017-07-20)"></a><a href="javascript:;" target="_blank" rel="noopener">2.2.4</a> (2017-07-20)<a class="article-anchor" href="#2-2-4-2017-07-20" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-14" class="article-heading"><a href="#Bug-Fixes-14" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-14" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> temporary fix for nuxt/nuxt.js#1127 (<a href="javascript:;" target="_blank" rel="noopener">499b639</a>), closes <a href="javascript:;" target="_blank" rel="noopener">nuxt/nuxt.js#1127</a></li>
</ul>
<p><a name="2.2.3"></a></p>
<h2 id="2-2-3-2017-07-19" class="article-heading"><a href="#2-2-3-2017-07-19" class="headerlink" title="2.2.3 (2017-07-19)"></a><a href="javascript:;" target="_blank" rel="noopener">2.2.3</a> (2017-07-19)<a class="article-anchor" href="#2-2-3-2017-07-19" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-15" class="article-heading"><a href="#Bug-Fixes-15" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-15" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> don’t proxy Host header from request (#72, #39) (<a href="javascript:;" target="_blank" rel="noopener">61462ca</a>)</li>
</ul>
<p><a name="2.2.2"></a></p>
<h2 id="2-2-2-2017-07-19" class="article-heading"><a href="#2-2-2-2017-07-19" class="headerlink" title="2.2.2 (2017-07-19)"></a><a href="javascript:;" target="_blank" rel="noopener">2.2.2</a> (2017-07-19)<a class="article-anchor" href="#2-2-2-2017-07-19" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-16" class="article-heading"><a href="#Bug-Fixes-16" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-16" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> don’t proxy Host header from request (#72, #39) (<a href="javascript:;" target="_blank" rel="noopener">61462ca</a>)</li>
</ul>
<p><a name="2.2.1"></a></p>
<h2 id="2-2-1-2017-07-15" class="article-heading"><a href="#2-2-1-2017-07-15" class="headerlink" title="2.2.1 (2017-07-15)"></a><a href="javascript:;" target="_blank" rel="noopener">2.2.1</a> (2017-07-15)<a class="article-anchor" href="#2-2-1-2017-07-15" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-17" class="article-heading"><a href="#Bug-Fixes-17" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-17" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> problems related to #65 (<a href="javascript:;" target="_blank" rel="noopener">4e7dd3f</a>)</li>
</ul>
<p><a name="2.0.3"></a></p>
<h2 id="2-0-3-2017-06-10" class="article-heading"><a href="#2-0-3-2017-06-10" class="headerlink" title="2.0.3 (2017-06-10)"></a><a href="javascript:;" target="_blank" rel="noopener">2.0.3</a> (2017-06-10)<a class="article-anchor" href="#2-0-3-2017-06-10" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-18" class="article-heading"><a href="#Bug-Fixes-18" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-18" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> Handle relative baseURL (<a href="javascript:;" target="_blank" rel="noopener">19b8453</a>)</li>
<li>handle 0.0.0.0 host (<a href="javascript:;" target="_blank" rel="noopener">610e0f5</a>)</li>
</ul>
<p><a name="2.0.2"></a></p>
<h2 id="2-0-2-2017-06-09" class="article-heading"><a href="#2-0-2-2017-06-09" class="headerlink" title="2.0.2 (2017-06-09)"></a><a href="javascript:;" target="_blank" rel="noopener">2.0.2</a> (2017-06-09)<a class="article-anchor" href="#2-0-2-2017-06-09" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-19" class="article-heading"><a href="#Bug-Fixes-19" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-19" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> Node 6.x support (<a href="javascript:;" target="_blank" rel="noopener">54deac0</a>)</li>
</ul>
<p><a name="2.0.1"></a></p>
<h2 id="2-0-1-2017-06-09" class="article-heading"><a href="#2-0-1-2017-06-09" class="headerlink" title="2.0.1 (2017-06-09)"></a><a href="javascript:;" target="_blank" rel="noopener">2.0.1</a> (2017-06-09)<a class="article-anchor" href="#2-0-1-2017-06-09" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-20" class="article-heading"><a href="#Bug-Fixes-20" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-20" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> ensure store exists before injecting (<a href="javascript:;" target="_blank" rel="noopener">23ad7b7</a>)</li>
</ul>
<p><a name="2.0.0"></a></p>
<h1 id="2-0-0-2017-06-09" class="article-heading"><a href="#2-0-0-2017-06-09" class="headerlink" title="2.0.0 (2017-06-09)"></a><a href="javascript:;" target="_blank" rel="noopener">2.0.0</a> (2017-06-09)<a class="article-anchor" href="#2-0-0-2017-06-09" aria-hidden="true"></a></h1><h3 id="Bug-Fixes-21" class="article-heading"><a href="#Bug-Fixes-21" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-21" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> install using Vue.use (<a href="javascript:;" target="_blank" rel="noopener">184651b</a>)</li>
<li><strong>axios:</strong> req typo (<a href="javascript:;" target="_blank" rel="noopener">16f28b1</a>)</li>
<li><strong>axios:</strong> use relative <code>API_URL</code> if same host and port else <code>API_URL</code> (<a href="javascript:;" target="_blank" rel="noopener">3421d19</a>)</li>
</ul>
<h3 id="Features-15" class="article-heading"><a href="#Features-15" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-15" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> AXIOS_CREDENTIALS, AXIOS_SSR_HEADERS (<a href="javascript:;" target="_blank" rel="noopener">4dfdc2d</a>)</li>
<li><strong>axios:</strong> don’t append optional config into env (<a href="javascript:;" target="_blank" rel="noopener">fe189e8</a>)</li>
<li><strong>axios:</strong> Easier API (<a href="javascript:;" target="_blank" rel="noopener">f54a434</a>)</li>
<li><strong>axios:</strong> New API (<a href="javascript:;" target="_blank" rel="noopener">0194226</a>)</li>
<li><strong>axios:</strong> nuxt friendly errors for SSR (<a href="javascript:;" target="_blank" rel="noopener">65bc50f</a>)</li>
</ul>
<h3 id="BREAKING-CHANGES-3" class="article-heading"><a href="#BREAKING-CHANGES-3" class="headerlink" title="BREAKING CHANGES"></a>BREAKING CHANGES<a class="article-anchor" href="#BREAKING-CHANGES-3" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> API_PREFIX is deprecated.</li>
</ul>
<p><a name="1.0.2"></a></p>
<h2 id="1-0-2-2017-05-29" class="article-heading"><a href="#1-0-2-2017-05-29" class="headerlink" title="1.0.2 (2017-05-29)"></a><a href="javascript:;" target="_blank" rel="noopener">1.0.2</a> (2017-05-29)<a class="article-anchor" href="#1-0-2-2017-05-29" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-22" class="article-heading"><a href="#Bug-Fixes-22" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-22" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> remove extra function call on computed prop (<a href="javascript:;" target="_blank" rel="noopener">cd9da0b</a>)</li>
</ul>
<p><a name="1.0.1"></a></p>
<h2 id="1-0-1-2017-05-26" class="article-heading"><a href="#1-0-1-2017-05-26" class="headerlink" title="1.0.1 (2017-05-26)"></a><a href="javascript:;" target="_blank" rel="noopener">1.0.1</a> (2017-05-26)<a class="article-anchor" href="#1-0-1-2017-05-26" aria-hidden="true"></a></h2><h3 id="Bug-Fixes-23" class="article-heading"><a href="#Bug-Fixes-23" class="headerlink" title="Bug Fixes"></a>Bug Fixes<a class="article-anchor" href="#Bug-Fixes-23" aria-hidden="true"></a></h3><ul>
<li><strong>axios:</strong> remove extra function call on computed prop (<a href="javascript:;" target="_blank" rel="noopener">cd9da0b</a>)</li>
</ul>
<p><a name="1.0.0"></a></p>
<h1 id="1-0-0-2017-05-26" class="article-heading"><a href="#1-0-0-2017-05-26" class="headerlink" title="1.0.0 (2017-05-26)"></a>1.0.0 (2017-05-26)<a class="article-anchor" href="#1-0-0-2017-05-26" aria-hidden="true"></a></h1><h3 id="Features-16" class="article-heading"><a href="#Features-16" class="headerlink" title="Features"></a>Features<a class="article-anchor" href="#Features-16" aria-hidden="true"></a></h3><ul>
<li>initial migration to 1.0.0-alpha1 (<a href="javascript:;" target="_blank" rel="noopener">05c1b7a</a>)</li>
</ul>
<h3 id="BREAKING-CHANGES-4" class="article-heading"><a href="#BREAKING-CHANGES-4" class="headerlink" title="BREAKING CHANGES"></a>BREAKING CHANGES<a class="article-anchor" href="#BREAKING-CHANGES-4" aria-hidden="true"></a></h3><ul>
<li>New modules system is backward incompatible with nuxt-helpers style modules</li>
</ul>
<p><a name="0.0.1"></a></p>
<h2 id="0-0-1-2017-05-10" class="article-heading"><a href="#0-0-1-2017-05-10" class="headerlink" title="0.0.1 (2017-05-10)"></a>0.0.1 (2017-05-10)<a class="article-anchor" href="#0-0-1-2017-05-10" aria-hidden="true"></a></h2><h2 id="📑-License" class="article-heading"><a href="#📑-License" class="headerlink" title="📑 License"></a>📑 License<a class="article-anchor" href="#📑-License" aria-hidden="true"></a></h2><p><a href="javascript:;">MIT License</a> - Nuxt Community</p>
<div class="recommand">以下课程十分推荐想往前端架构师方向精进的同学，月入5万的梦想总要有的！投资自己就是最好的投资！</div><div class="lessonlist"><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les01.jpeg" class="lesspic"></a></div><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les02.jpeg" class="lesspic"></a></div><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les03.jpeg" class="lesspic"></a></div><div class="lession"><a href="javascript:;" target="_blank" rel="noopener"><img src="static/picture/les04.jpeg" class="lesspic"></a></div></div>
              </div>
              <footer class="article-footer">
                <time class="article-footer-updated" datetime="2021-10-28T14:06:35.000Z" itemprop="dateModified">上次更新：2021-10-28</time>
                <a href="vue-axios.html" class="article-footer-prev" title="vue-axios"><i class="fa fa-chevron-left"></i><span>上一页</span></a><a href="react-axios.html" class="article-footer-next" title="react-axios"><span>下一页</span><i class="fa fa-chevron-right"></i></a>
              </footer>
              
            </div>
          </div>
          <aside id="article-toc" role="navigation">
            <div id="article-toc-inner">
              <strong class="sidebar-title">目录</strong>
              <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#📦-Axios-模块"><span class="toc-text">📦 Axios 模块</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#✅-特点"><span class="toc-text">✅ 特点</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装"><span class="toc-text">安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#使用"><span class="toc-text">使用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#组件"><span class="toc-text">组件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Store-nuxtServerInit"><span class="toc-text">Store nuxtServerInit</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Store-actions"><span class="toc-text">Store actions</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#扩展Axios"><span class="toc-text">扩展Axios</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#帮助"><span class="toc-text">帮助</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#拦截器"><span class="toc-text">拦截器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Fetch-风格请求"><span class="toc-text">Fetch 风格请求</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setHeader-name-value-scopes-39-common-39"><span class="toc-text">setHeader(name, value, scopes&#x3D;&#39;common&#39;)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setToken-token-type-scopes-39-common-39"><span class="toc-text">setToken(token, type, scopes&#x3D;&#39;common&#39;)</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#选项"><span class="toc-text">选项</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#prefix-host-and-port"><span class="toc-text">prefix, host and port</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#baseURL"><span class="toc-text">baseURL</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#browserBaseURL"><span class="toc-text">browserBaseURL</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#https"><span class="toc-text">https</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#progress"><span class="toc-text">progress</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#proxy"><span class="toc-text">proxy</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#retry"><span class="toc-text">retry</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#credentials"><span class="toc-text">credentials</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#debug"><span class="toc-text">debug</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#proxyHeaders"><span class="toc-text">proxyHeaders</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#proxyHeadersIgnore"><span class="toc-text">proxyHeadersIgnore</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#From-4-x-to-5-x"><span class="toc-text">From 4.x to 5.x</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Change-Log"><span class="toc-text">Change Log</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#5-3-2-2018-09-21"><span class="toc-text">5.3.2 (2018-09-21)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-3-1-2018-03-31"><span class="toc-text">5.3.1 (2018-03-31)</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-3-0-2018-03-31"><span class="toc-text">5.3.0 (2018-03-31)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features"><span class="toc-text">Features</span></a></li></ol></li></ol><li class="toc-item toc-level-1"><a class="toc-link" href="#5-2-0-2018-03-31"><span class="toc-text">5.2.0 (2018-03-31)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-1"><span class="toc-text">Bug Fixes</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-1"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-1-1-2018-03-06"><span class="toc-text">5.1.1 (2018-03-06)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-2"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-1-0-2018-03-05"><span class="toc-text">5.1.0 (2018-03-05)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-2"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-0-1-2018-02-08"><span class="toc-text">5.0.1 (2018-02-08)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-3"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-0-0-2018-02-04"><span class="toc-text">5.0.0 (2018-02-04)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-4"><span class="toc-text">Bug Fixes</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-3"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-0-0-rc-2-2018-01-29"><span class="toc-text">5.0.0-rc.2 (2018-01-29)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-5"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-0-0-rc-1-2018-01-28"><span class="toc-text">5.0.0-rc.1 (2018-01-28)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-6"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-0-0-rc-0-2018-01-28"><span class="toc-text">5.0.0-rc.0 (2018-01-28)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-4"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-0-0-alpha-1-2018-01-28"><span class="toc-text">5.0.0-alpha.1 (2018-01-28)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-5"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-0-0-alpha-0-2018-01-28"><span class="toc-text">5.0.0-alpha.0 (2018-01-28)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Code-Refactoring"><span class="toc-text">Code Refactoring</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-6"><span class="toc-text">Features</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#BREAKING-CHANGES"><span class="toc-text">BREAKING CHANGES</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-5-2-2017-12-29"><span class="toc-text">4.5.2 (2017-12-29)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-5-1-2017-12-29"><span class="toc-text">4.5.1 (2017-12-29)</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-5-0-2017-11-16"><span class="toc-text">4.5.0 (2017-11-16)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-7"><span class="toc-text">Bug Fixes</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-7"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-4-0-2017-09-30"><span class="toc-text">4.4.0 (2017-09-30)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-8"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-3-1-2017-09-28"><span class="toc-text">4.3.1 (2017-09-28)</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-3-0-2017-09-11"><span class="toc-text">4.3.0 (2017-09-11)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-9"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-2-1-2017-09-08"><span class="toc-text">4.2.1 (2017-09-08)</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-2-0-2017-09-08"><span class="toc-text">4.2.0 (2017-09-08)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-10"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-1-1-2017-09-06"><span class="toc-text">4.1.1 (2017-09-06)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-8"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-1-0-2017-09-06"><span class="toc-text">4.1.0 (2017-09-06)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-9"><span class="toc-text">Bug Fixes</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-11"><span class="toc-text">Features</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Performance-Improvements"><span class="toc-text">Performance Improvements</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-0-1-2017-09-04"><span class="toc-text">4.0.1 (2017-09-04)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-10"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-0-0-2017-08-30"><span class="toc-text">4.0.0 (2017-08-30)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-12"><span class="toc-text">Features</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#BREAKING-CHANGES-1"><span class="toc-text">BREAKING CHANGES</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1-4-2017-08-13"><span class="toc-text">3.1.4 (2017-08-13)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-11"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1-3-2017-08-13"><span class="toc-text">3.1.3 (2017-08-13)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-12"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1-1-2017-08-13"><span class="toc-text">3.1.1 (2017-08-13)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-13"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-0-1-2017-07-25"><span class="toc-text">3.0.1 (2017-07-25)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-13"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3-0-0-2017-07-25"><span class="toc-text">3.0.0 (2017-07-25)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Code-Refactoring-1"><span class="toc-text">Code Refactoring</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#BREAKING-CHANGES-2"><span class="toc-text">BREAKING CHANGES</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-3-0-2017-07-24"><span class="toc-text">2.3.0 (2017-07-24)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-14"><span class="toc-text">Features</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-4-2017-07-20"><span class="toc-text">2.2.4 (2017-07-20)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-14"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-3-2017-07-19"><span class="toc-text">2.2.3 (2017-07-19)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-15"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-2-2017-07-19"><span class="toc-text">2.2.2 (2017-07-19)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-16"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-1-2017-07-15"><span class="toc-text">2.2.1 (2017-07-15)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-17"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-0-3-2017-06-10"><span class="toc-text">2.0.3 (2017-06-10)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-18"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-0-2-2017-06-09"><span class="toc-text">2.0.2 (2017-06-09)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-19"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-0-1-2017-06-09"><span class="toc-text">2.0.1 (2017-06-09)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-20"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-0-0-2017-06-09"><span class="toc-text">2.0.0 (2017-06-09)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-21"><span class="toc-text">Bug Fixes</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-15"><span class="toc-text">Features</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#BREAKING-CHANGES-3"><span class="toc-text">BREAKING CHANGES</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-0-2-2017-05-29"><span class="toc-text">1.0.2 (2017-05-29)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-22"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-0-1-2017-05-26"><span class="toc-text">1.0.1 (2017-05-26)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Bug-Fixes-23"><span class="toc-text">Bug Fixes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#1-0-0-2017-05-26"><span class="toc-text">1.0.0 (2017-05-26)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Features-16"><span class="toc-text">Features</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#BREAKING-CHANGES-4"><span class="toc-text">BREAKING CHANGES</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0-0-1-2017-05-10"><span class="toc-text">0.0.1 (2017-05-10)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#📑-License"><span class="toc-text">📑 License</span></a></li>
              <a href="#" id="article-toc-top">回到顶部</a>
            </div>
          </aside>
        </div>
      </article>
      <aside id="sidebar" role="navigation">
  <div class="inner">
    <strong class="sidebar-title">开始使用</strong><a href="index1.html" class="sidebar-link">概述</a><strong class="sidebar-title">框架整合</strong><a href="vue-axios.html" class="sidebar-link">vue-axios</a><a href="" class="sidebar-link current">nuxtjs-axios</a><a href="react-axios.html" class="sidebar-link">react-axios</a><strong class="sidebar-title">Plugins</strong><a href="axios-retry.html" class="sidebar-link">axios-retry</a><a href="vue-axios-plugin.html" class="sidebar-link">vue-axios-plugin</a>
  </div>
</aside>
    </div>
  </div>
</div>

    <footer id="footer" class="wrapper">
  <div class="inner">
    <div id="footer-copyright">
      &copy; 2021 axios中文网<br>
      Documentation licensed under <a href="javascript:;" target="_blank">CC BY 4.0</a>.
    </div>
    <div id="footer-links">
      <a href="javascript:;" class="footer-link" target="_blank"><i class="fa fa-twitter"></i></a>
      <a href="javascript:;" class="footer-link" target="_blank"><i class="fa fa-github-alt"></i></a>
    </div>
  </div>
</footer>

  </div>
  <div id="mobile-nav-dimmer"></div>
  <nav id="mobile-nav">
  <div id="mobile-nav-inner">
    <ul id="mobile-nav-list">
      <a href="index1.html" class="mobile-nav-link">文档</a><a href="index2.html" class="mobile-nav-link">博客</a>
      <li class="mobile-nav-item">
        <a href="javascript:;" class="mobile-nav-link" rel="external" target="_blank">GitHub</a>
      </li>
    </ul>
    
      <strong class="mobile-nav-title">开始使用</strong><a href="index1.html" class="mobile-nav-link">概述</a><strong class="mobile-nav-title">框架整合</strong><a href="vue-axios.html" class="mobile-nav-link">vue-axios</a><a href="" class="mobile-nav-link current">nuxtjs-axios</a><a href="react-axios.html" class="mobile-nav-link">react-axios</a><strong class="mobile-nav-title">Plugins</strong><a href="axios-retry.html" class="mobile-nav-link">axios-retry</a><a href="vue-axios-plugin.html" class="mobile-nav-link">vue-axios-plugin</a>
    
  </div>
  <div id="mobile-lang-select-wrap">
    <span id="mobile-lang-select-label"><i class="fa fa-globe"></i><span>简体中文</span></span>
    <select id="mobile-lang-select" data-canonical="docs/nuxtjs-axios.html">
      
        <option value="en">undefined</option>
      
        <option value="zh-cn" selected="">简体中文</option>
      
    </select>
  </div>
</nav>
  <!-- Scripts -->
<!-- build:js build/js/main.js -->

<script src="static/js/lang_select.js"></script>


<script src="static/js/toc.js"></script>


<script src="static/js/mobile_nav.js"></script>

<!-- endbuild -->

<!-- Algolia -->




<div class="popup-container">
  
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/1.0.1/pure-min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.css">
<style>
    #magic-popup {
        color: #000;
        
    }
    .vultr-coupon {
        margin-top: 20px
    }
    .popup-container {
        visibility: hidden;
        position: relative
    }

    .coupon {
        font-size: 16px;
    }
    .desc {
        margin-top: 10px;
        color: #03a9f4;
        font-size: 16px;
    }
    .reason {
        position: absolute;
        bottom: 0;
        right: 10px;
        width: 100%;
        font-size: 12px;
        color: red
    }

    .red-packet {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    #magic-popup{
        height: 200px
    }

    .campaign-tip {
        font-size: 14px;
        letter-spacing: 0
    }
</style>
<div class="popup-container">
<div id="magic-popup" class="magic-popup">
    <div class="pure-g"> 
            <a href="javascript:;" class="red-packet">
            <img width="150" src="https://res.cloudinary.com/dq9x329zv/image/upload/v1600435375/redpacket_n6cqu1.jpg">
            
            <span class="campaign-tip">拼多多新人专享红包！最高188元，限时领取！还有新人0元购，更多福利等你来拿~>></span>
            </a>
    </div>

    <!-- >
    <div class="pure-g">
            <div class="pure-u-12-24">
              <a class="pure-button pure-button-primary coupon" href="http://bit.ly/2PpdaHG" target="_blank" rel="noopener" class="btn btn-default btn-md" role="button">virmach特价vps</a>
            </div>

            <div class="pure-u-12-24">
              <a class="pure-button pure-button-primary coupon" href="http://bit.ly/2NDPn4N" target="_blank" rel="noopener" class="btn btn-default btn-md" role="button">vultr新户送$100</a>
            </div>
                
    </div>
    <div class="desc">
    vps可用来搭建博客，学习Linux，搭建个人网盘，私人git，
    可以搭建ssr一键使用google,搜索资料更方便。以上支持支付宝付款。
    </div>

    <div class="reason">
        广告费用用于支持本站服务器费用，希望大家理解
    </div> 

    <-->

    
    
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.all.js"></script>
<script src="static/js/js.cookie.min.js"></script>

<script type="text/javascript">
var result = Cookies.get('popuped');
if(result){

} else {
Cookies.set('popuped', '1', { expires: 7 })
// Swal.fire({
//   title: '<strong></strong>',
//   icon: 'info',
//   html: $('#magic-popup'),
//   focusConfirm: false,
//   confirmButtonText: '知道了'
// })
}


</script>





</body>
</html>